import request from '@/utils/requestUtil'

export function searchProductList(params) {
	// 如果有关键字参数，从params中取出并构建URL
	let url = '/product/search';
	if (params.keyword) {
		// 直接在URL中添加关键字参数，不进行编码
		const keyword = params.keyword;
		delete params.keyword; // 从params中删除，防止被二次编码
		url = `${url}?keyword=${keyword}`;
	}
	
	return request({
		method: 'GET',
		url: url,
		params: params
	})
}

export function fetchCategoryTreeList() {
	return request({
		method: 'GET',
		url: '/product/categoryTreeList'
	})
}

export function fetchProductDetail(id) {
	return request({
		method: 'GET',
		url: '/product/detail/'+id
	})
}
